﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Diagnostics;

namespace Sami_SMS_CRM_UI
{
    public partial class Tracking : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [WebMethod]
        public static object GetService()
        {
            string serviceName = System.Configuration.ConfigurationManager.AppSettings["ServiceName"];
            string serviceStatus;
            var processes = Process.GetProcessesByName(serviceName).FirstOrDefault();
            if (processes == null)
            {
                serviceStatus = "Don't run";
            }
            else
            {
                serviceStatus = "Running";
            }

            return new ServiceInfo()
            {
                ServiceName = serviceName,
                ServiceStatus = serviceStatus
            };
            
        }

        internal class ServiceInfo
        {
            public string ServiceName;
            public string ServiceStatus;
        }
    }
}